/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.preguntas.ejb;

import com.preguntas.entity.Preguntas;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author jubarcos
 */
@Stateless
public class PreguntasFacade extends AbstractFacade<Preguntas> {

    @PersistenceContext(unitName = "trivia-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public PreguntasFacade() {
        super(Preguntas.class);
    }

    public List<Preguntas> searchLike(String pregunta) {
        Query query = em.createNamedQuery("Preguntas.findByLike");
        query.setParameter("pregunta", "%" + pregunta + "%");
        List<Preguntas> result = (List<Preguntas>) query.getResultList();
        return result;

    }
   
}
